//
//  AbsentCell.m
//  sooc-ios_new
//
//  Created by apple on 15/12/28.
//  Copyright © 2015年 xuguangChao. All rights reserved.
//
#define REDCOLOR [self getColor:@"e86666"]

#import "AbsentCell.h"
#import "UIView+WHC_AutoLayout.h"
#import "MMLabel.h"
#import "AbsentModel.h"

@implementation AbsentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _nameLabel = [UILabel new];
        _quexiLabel = [MMLabel new];
        _classLabel = [UILabel new];
        
        _nameLabel.font = NormalFont(42);
        _nameLabel.textColor = Color333333;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _classLabel.font = NormalFont(36);
        _classLabel.textColor = Color333333;
        _classLabel.textAlignment = NSTextAlignmentLeft;
        _quexiLabel.textColor = Color333333;
        _quexiLabel.font = NormalFont(39);
        _quexiLabel.textAlignment = NSTextAlignmentRight;

        [self.contentView addSubview:_nameLabel];
        [self.contentView addSubview:_quexiLabel];
        [self.contentView addSubview:_classLabel];
        
        
        _nameLabel.whc_LeftSpace(ScaleSize(42))
                    .whc_RightSpace(ScaleSize(42))
                    .whc_TopSpace(ScaleSize(63))
                    .whc_heightAuto();
        
        _classLabel.whc_LeftSpace(ScaleSize(42))
                    .whc_TopSpaceToView(ScaleSize(63),_nameLabel)
                    .whc_Size(CGSizeMake(200, 21));
        
        
        _quexiLabel.whc_RightSpace(ScaleSize(42))
                    .whc_TopSpaceToView(ScaleSize(63),_nameLabel)
                    .whc_Size(CGSizeMake(120, 21));
        

    }
    return  self;
}

- (void)setMyModel:(AbsentModel *)myModel{

    _myModel = myModel;
    
    _nameLabel.text = [NSString stringWithFormat:@"%@(%@)", myModel.xm, myModel.xh];
    
    _classLabel.text = [NSString stringWithFormat:@"%@", myModel.bj];
    
    _quexiLabel.text = [NSString stringWithFormat:@"缺席次数：%@", myModel.qxcs];

    _quexiLabel.keyWord = myModel.qxcs;

    _quexiLabel.keyWordColor = REDCOLOR;

}

//16进制颜色转换
-(UIColor *)getColor:(NSString *)hexColor {
    unsigned int red,green,blue;
    NSRange range;
    range.length = 2;
    
    range.location = 0;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
    
    range.location = 2;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
    
    range.location = 4;
    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
    
    return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green / 255.0f) blue:(float)(blue / 255.0f) alpha:1.0f];
}
@end
